package iso2.struts2;
import java.sql.SQLException;

import iso2.dominio.*;
import iso2.persistencia.ConexionesOcupadasException;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;

@SuppressWarnings("serial") 
public class ModificarCuentaUsuario extends ActionSupport {  
	
	private String oldPassword;
	private String newPassword1;
	private String newPassword2;
	private String newDireccion;
	
	public String execute() {

		Usuario usuario = 
			(Usuario)ActionContext.getContext().getSession().get("usuario");
		
    	try {
    		usuario.updateUsuario(oldPassword, newPassword1, 
    							  newPassword2, newDireccion);
    		return SUCCESS;
		} catch (SQLException e) {
			ActionContext.getContext().getSession().put("excepcion", e);
			return "SQLException";
		} catch (UsuarioInvalidoException e) {
			ActionContext.getContext().getSession().put("excepcion", e);
			return "UsuarioInvalidoException";
		} catch (ConexionesOcupadasException e) {
			ActionContext.getContext().getSession().put("excepcion", e);
			return "ConexionesOcupadasException";
		} catch (ClaveInvalidaException e) {
			ActionContext.getContext().getSession().put("excepcion", e);
			return "ClaveInvalidaException";
		} catch (UsuarioCanceladoException e) {
			ActionContext.getContext().getSession().put("excepcion", e);
			return "UsuarioCanceladoException";
		} catch (ClaveNuevaException e) {
			ActionContext.getContext().getSession().put("excepcion", e);
			return "ClaveNuevaException";
		} 
	}

	public String getOldPassword() {
		return oldPassword;
	}

	public void setOldPassword(String oldPassword) {
		this.oldPassword = oldPassword;
	}

	public String getNewPassword1() {
		return newPassword1;
	}

	public void setNewPassword1(String newPassword1) {
		this.newPassword1 = newPassword1;
	}

	public String getNewPassword2() {
		return newPassword2;
	}

	public void setNewPassword2(String newPassword2) {
		this.newPassword2 = newPassword2;
	}

	public String getDireccion() {
		return newDireccion;
	}

	public void setDireccion(String newDireccion) {
		this.newDireccion = newDireccion;
	}

	
}  